home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / Sources / CAHandlers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-04  |  46.7 KB  |  1,336 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Program Name:    Stiletto                                                                    */
  4. /*                                                                                                */
  5. /*    File Name:        CAHandlers.c                                                                */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-07-04    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "TextUtils.h"
  26. #include "Types.h"
  27.  
  28. #include "Telephones.h"
  29.  
  30. #include "CAHandlers.h"
  31. #include "Constants.h"
  32. #include "DNWindow.h"
  33. #include "LogWindow.h"
  34. #include "Utilities.h"
  35.  
  36. /****************************************** DEFINITIONS *****************************************/
  37.  
  38. /****************************************** PROTOTYPES ******************************************/
  39.  
  40. void    HandleCAAlertingMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  41. void    HandleCAOfferMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  42. void    HandleCAProgressMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  43. void    HandleCAOutgoingMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  44. void    HandleCADisconMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  45. void    HandleCAActiveMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  46. void    HandleCAConfMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  47. void    HandleCATransfMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  48. void    HandleCAHeldMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  49. void    HandleCADigitsMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  50. void    HandleCAParkedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  51. void    HandleCACallBackMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  52. void    HandleCARejectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  53. void    HandleCADeflectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  54. void    HandleCAForwardedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  55. void    HandleCAConfSplitMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  56. void    HandleCAConfDropMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  57. void    HandleCAQueuedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  58. void    HandleCAInUseMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  59. void    HandleCAPickUpMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  60. void    HandleCAPagingMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  61. void    HandleCAInterComMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  62. void    HandleCAModemToneMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  63. void    HandleCAFaxToneMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  64. void    HandleCAIdleMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  65. void    HandleCASuccessiveAlertMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  66. void    HandleCAOtherMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  67. void    HandleCAUserUserInfoMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  68.  
  69. void    HandleCAHandOffMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  70. void    HandleCAVoiceDetectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  71. void    HandleCASilenceDetectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  72. void    HandleCAEnergyDetectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  73. void    HandleCADigitsImmMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo);
  74.  
  75. /******************************************** GLOBALS *******************************************/
  76.  
  77. extern    LogWindowPtr        gLogWindow;
  78. extern    TELCAHandle            gAvailableCA;
  79.  
  80. extern    TelephoneCAMsgUPP    gCAMsgHandlerUPP;
  81. extern    TelephoneCAMsgUPP    gCAConfMsgHandlerUPP;
  82.  
  83. /************************************************************************************************/
  84. /************************************************************************************************/
  85.  
  86.  
  87. #pragma segment CAHandlers
  88. OSErr    InstallCAHandler (TELDNHandle dnHand)
  89. {
  90.     OSErr        errCode;
  91.     
  92.     errCode = TELCAMsgHand (dnHand, telCAOtherMsg | telAllCAMsgs, gCAMsgHandlerUPP, SetCurrentA5());
  93.  
  94.     if (errCode != noErr)
  95.         PutCLine (gLogWindow, kErrorColor, "### TELCAMsgHand fails : %d", errCode);
  96.     
  97.     return (errCode);
  98. }
  99.  
  100.  
  101. pascal void    AllCAMsgsHandler (TELCAHandle caHand, long msg, short mtype, short value, Ptr msgInfo, long ourA5)
  102. {
  103. #pragma unused (mtype, value, msgInfo)
  104.  
  105.     long    oldA5;
  106.     char     *msgString;
  107.     
  108.     oldA5 = SetA5 (ourA5);
  109.     
  110.     switch (msg) {
  111.         case telCAAlertingMsg             : msgString = "telCAAlertingMsg"; break;
  112.         case telCAOfferMsg                 : msgString = "telCAOfferMsg"; break;
  113.         case telCAProgressMsg             : msgString = "telCAProgressMsg"; break;
  114.         case telCAOutgoingMsg             : msgString = "telCAOutgoingMsg"; break;
  115.         case telCADisconnectMsg         : msgString = "telCADisconnectMsg"; break;
  116.         case telCAActiveMsg             : msgString = "telCAActiveMsg"; break;
  117.         case telCAConferenceMsg         : msgString = "telCAConferenceMsg"; break;
  118.         case telCATransferMsg             : msgString = "telCATransferMsg"; break;
  119.         case telCAHoldMsg                 : msgString = "telCAHoldMsg"; break;
  120.         case telCADigitsMsg             : msgString = "telCADigitsMsg"; break;
  121.         case telCACallParkMsg             : msgString = "telCACallParkMsg"; break;
  122.         case telCACallbackMsg             : msgString = "telCACallbackMsg"; break;
  123.         case telCARejectMsg             : msgString = "telCARejectMsg"; break;
  124.         case telCADeflectMsg             : msgString = "telCADeflectMsg"; break;
  125.         case telCAForwardMsg             : msgString = "telCAForwardMsg"; break;
  126.         case telCAConferenceSplitMsg     : msgString = "telCAConferenceSplitMsg"; break;
  127.         case telCAConferenceDropMsg     : msgString = "telCAConferenceDropMsg"; break;
  128.         case telCAQueuedMsg             : msgString = "telCAQueuedMsg"; break;
  129.         case telCAInUseMsg                 : msgString = "telCAInUseMsg"; break;
  130.         case telCACallPickupMsg         : msgString = "telCACallPickupMsg"; break;
  131.         case telCAPagingMsg             : msgString = "telCAPagingMsg"; break;
  132.         case telCAIntercomMsg             : msgString = "telCAIntercomMsg"; break;
  133.         case telCAModemToneMsg             : msgString = "telCAModemToneMsg"; break;
  134.         case telCAFaxToneMsg             : msgString = "telCAFaxToneMsg"; break;
  135.         case telCAIdleMsg                 : msgString = "telCAIdleMsg"; break;
  136.         case telCASuccessiveAlertMsg     : msgString = "telCASuccessiveAlertMsg"; break;
  137.         case telCAUserUserInfoMsg        : msgString = "telCAUserUserInfoMsg"; break;
  138.         
  139.         case telCAHandOffMsg            : msgString = "telCAHandOffMsg"; break;
  140.         case telCAVoiceDetectedMsg        : msgString = "telCAVoiceDetectedMsg"; break;
  141.         case telCASilenceDetectedMsg    : msgString = "telCASilenceDetectedMsg"; break;
  142. //        case telCAEnergyDetectedMsg        : msgString = "telCAEnergyDetectedMsg"; break;
  143.         case telCADigitsImmMsg            : msgString = "telCADigitsImmMsg"; break;
  144.  
  145.         case telCAOtherMsg                 : msgString = "telCAOtherMsg"; break;
  146.             
  147.         default :
  148.             PutCLine (gLogWindow, kErrorColor, "### Unknown caMsg : %08x", msg);
  149.             msgString = "### Unknown";
  150.     }
  151.     PutLine (gLogWindow, ">>> got a CA message (%08x) : %s", caHand, msgString);
  152.     
  153.     (void) SetA5 (oldA5);
  154. }
  155.  
  156.  
  157. pascal void    CAActiveMsgHandler (TELCAHandle caHand, long msg, short mtype, short value, Ptr msgInfo, long ourA5)
  158. {
  159. #pragma unused (mtype, value, msgInfo)
  160.  
  161.     long        oldA5;
  162.     
  163.     oldA5 = SetA5 (ourA5);
  164.     
  165.     if (msg == telCAActiveMsg)
  166.         PutLine (gLogWindow, "=== telCAActiveMsg (%08x)", caHand);
  167.     else
  168.         PutCLine (gLogWindow, kErrorColor, "### Expect a telCAActiveMsg but got : %d", msg);
  169.     
  170.     (void) SetA5 (oldA5);
  171. }
  172.  
  173.  
  174. pascal void    CAConfMsgHandler (TELCAHandle caHand, long msg, short mtype, short value, Ptr msgInfo, long ourA5)
  175. {
  176. #pragma unused (msg, mtype, value, msgInfo)
  177.  
  178.     long        oldA5;
  179.     CAWindowPtr    caWindow;
  180.     OSErr        errCode;
  181.     
  182.     oldA5 = SetA5 (ourA5);
  183.     
  184.     if (msg == telCAActiveMsg) {
  185.         if (caHand != nil) {
  186.             caWindow = (CAWindowPtr) (*caHand)->userData;
  187.             if (caWindow->fConfInitiated) {
  188.                 HiliteControl (caWindow->fConf, 0);        // enable it
  189.                 
  190.                 if ((errCode = TELClrCAMsgHand ((*caHand)->hTELDN, gCAConfMsgHandlerUPP) != noErr))
  191.  
  192.                     PutCLine (gLogWindow, kErrorColor, "### TELClrCAMsgHand fails : %d", errCode);
  193.             }
  194.         }
  195.     } else
  196.         PutCLine (gLogWindow, kErrorColor, "### Expect a telCAActiveMsg but got : %08x", msg);
  197.     
  198.     (void) SetA5 (oldA5);
  199. }
  200.  
  201.  
  202. pascal void    CAMsgHandler (TELCAHandle caHand, long msg, short mtype, short value, Ptr msgInfo, long ourA5)
  203. {
  204.     long    oldA5;
  205.     
  206.     oldA5 = SetA5 (ourA5);
  207.     
  208.     switch (msg) {
  209.         case telCAAlertingMsg :
  210.             HandleCAAlertingMsg (caHand, mtype, value, msgInfo);
  211.             break;
  212.             
  213.         case telCAOfferMsg :
  214.             HandleCAOfferMsg (caHand, mtype, value, msgInfo);
  215.             break;
  216.             
  217.         case telCAProgressMsg :
  218.             HandleCAProgressMsg (caHand, mtype, value, msgInfo);
  219.             break;
  220.             
  221.         case telCAOutgoingMsg :
  222.             HandleCAOutgoingMsg (caHand, mtype, value, msgInfo);
  223.             break;
  224.             
  225.         case telCADisconnectMsg :
  226.             HandleCADisconMsg (caHand, mtype, value, msgInfo);
  227.             break;
  228.             
  229.         case telCAActiveMsg :
  230.             HandleCAActiveMsg (caHand, mtype, value, msgInfo);
  231.             break;
  232.             
  233.         case telCAConferenceMsg :
  234.             HandleCAConfMsg (caHand, mtype, value, msgInfo);
  235.             break;
  236.             
  237.         case telCATransferMsg :
  238.             HandleCATransfMsg (caHand, mtype, value, msgInfo);
  239.             break;
  240.             
  241.         case telCAHoldMsg :
  242.             HandleCAHeldMsg (caHand, mtype, value, msgInfo);
  243.             break;
  244.             
  245.         case telCADigitsMsg :
  246.             HandleCADigitsMsg (caHand, mtype, value, msgInfo);
  247.             break;
  248.             
  249.         case telCACallParkMsg :
  250.             HandleCAParkedMsg (caHand, mtype, value, msgInfo);
  251.             break;
  252.             
  253.         case telCACallbackMsg :
  254.             HandleCACallBackMsg (caHand, mtype, value, msgInfo);
  255.             break;
  256.             
  257.         case telCARejectMsg :
  258.             HandleCARejectedMsg (caHand, mtype, value, msgInfo);
  259.             break;
  260.             
  261.         case telCADeflectMsg :
  262.             HandleCADeflectedMsg (caHand, mtype, value, msgInfo);
  263.             break;
  264.             
  265.         case telCAForwardMsg :
  266.             HandleCAForwardedMsg (caHand, mtype, value, msgInfo);
  267.             break;
  268.             
  269.         case telCAConferenceSplitMsg :
  270.             HandleCAConfSplitMsg (caHand, mtype, value, msgInfo);
  271.             break;
  272.             
  273.         case telCAConferenceDropMsg :
  274.             HandleCAConfDropMsg (caHand, mtype, value, msgInfo);
  275.             break;
  276.             
  277.         case telCAQueuedMsg :
  278.             HandleCAQueuedMsg (caHand, mtype, value, msgInfo);
  279.             break;
  280.             
  281.         case telCAInUseMsg :
  282.             HandleCAInUseMsg (caHand, mtype, value, msgInfo);
  283.             break;
  284.             
  285.         case telCACallPickupMsg :
  286.             HandleCAPickUpMsg (caHand, mtype, value, msgInfo);
  287.             break;
  288.             
  289.         case telCAPagingMsg :
  290.             HandleCAPagingMsg (caHand, mtype, value, msgInfo);
  291.             break;
  292.             
  293.         case telCAIntercomMsg :
  294.             HandleCAInterComMsg (caHand, mtype, value, msgInfo);
  295.             break;
  296.             
  297.         case telCAModemToneMsg :
  298.             HandleCAModemToneMsg (caHand, mtype, value, msgInfo);
  299.             break;
  300.             
  301.         case telCAFaxToneMsg :
  302.             HandleCAFaxToneMsg (caHand, mtype, value, msgInfo);
  303.             break;
  304.             
  305.         case telCAIdleMsg :
  306.             HandleCAIdleMsg (caHand, mtype, value, msgInfo);
  307.             break;
  308.             
  309.         case telCASuccessiveAlertMsg :
  310.             HandleCASuccessiveAlertMsg (caHand, mtype, value, msgInfo);
  311.             break;
  312.             
  313.         case telCAUserUserInfoMsg :
  314.             HandleCAUserUserInfoMsg (caHand, mtype, value, msgInfo);
  315.             break;
  316.             
  317.  
  318.         case telCAHandOffMsg :
  319.             HandleCAHandOffMsg (caHand, mtype, value, msgInfo);
  320.             break;
  321.  
  322.         case telCAVoiceDetectedMsg :
  323.             HandleCAVoiceDetectedMsg (caHand, mtype, value, msgInfo);
  324.             break;
  325.  
  326.         case telCASilenceDetectedMsg :
  327.             HandleCASilenceDetectedMsg (caHand, mtype, value, msgInfo);
  328.             break;
  329.  
  330. //        case telCAEnergyDetectedMsg :
  331. //            HandleCAEnergyDetectedMsg (caHand, mtype, value, msgInfo);
  332. //            break;
  333.  
  334.         case telCADigitsImmMsg :
  335.             HandleCADigitsImmMsg (caHand, mtype, value, msgInfo);
  336.             break;
  337.  
  338.  
  339.         case telCAOtherMsg :
  340.             HandleCAOtherMsg (caHand, mtype, value, msgInfo);
  341.             break;
  342.             
  343.         default :
  344.             PutCLine (gLogWindow, kErrorColor, "### Unknown caMsg : %08x", msg);
  345.     }
  346.     
  347.     if (caHand != nil)
  348.         if (msg != telCAIdleMsg)
  349.             UpdateCAListState (GetDNWindow (caHand), caHand);
  350.     
  351.     (void) SetA5 (oldA5);
  352. }
  353.  
  354.  
  355. void    HandleCAAlertingMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  356. {
  357. #pragma unused (mtype, msgInfo)
  358.     DNWindowPtr            dnWindow;
  359.     
  360.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAAlertingMsg (%08x) --> pattern# = %d", caHand, value);
  361.     
  362.     if (caHand != nil)
  363.     {
  364.         dnWindow = GetDNWindow (caHand);
  365.         if (dnWindow != nil)
  366.             AppendCAList (dnWindow, caHand);
  367.         else
  368.             PutCLine (gLogWindow, kErrorColor, "### Can't find the corresponding dnWindow");
  369.     }
  370. }
  371.  
  372.  
  373. void    HandleCAOfferMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  374. {
  375. #pragma unused (mtype, value, msgInfo)
  376.     
  377.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAOfferMsg (%08x)", caHand);
  378. }
  379.  
  380.  
  381. void    HandleCAProgressMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  382. {
  383. #pragma unused (mtype)
  384.     char * valueStr;
  385.     Str255    tString;
  386.     
  387.     switch (value) {
  388.         case telCAPDialTone :
  389.             valueStr = "telCAPDialTone";
  390.             break;
  391.         case telCAPRinging :
  392.             valueStr = "telCAPRinging";
  393.             break;
  394.         case telCAPDialing :
  395.             valueStr = "telCAPDialing";
  396.             break;
  397.         case telCAPReorder :
  398.             valueStr = "telCAPReorder";
  399.             break;
  400.         case telCAPBusy :
  401.             valueStr = "telCAPBusy";
  402.             break;
  403.         case telCAPRouted :
  404.             valueStr = "telCAPRouted";
  405.             break;
  406.         case telCAPRoutedOff :
  407.             valueStr = "telCAPRoutedOff";
  408.             break;
  409.         case telCAPTimeout :
  410.             valueStr = "telCAPTimeout";
  411.             break;
  412.         case telCAPUpdate :
  413.             valueStr = "telCAPUpdate";
  414.             break;
  415.         case telCAPPrompt :
  416.             valueStr = "telCAPPrompt";
  417.             break;
  418.         case telCAPWaiting :
  419.             valueStr = "telCAPWaiting";
  420.             break;
  421.         case telCAPCPC :
  422.             valueStr = "telCAPCPC";
  423.             break;
  424.         case telCAPNoDialTone :
  425.             valueStr = "telCAPNoDialTone";
  426.             break;
  427.         case telCAPUnknown :
  428.             valueStr = "telCAPUnknown";
  429.             break;
  430.         default :
  431.             valueStr = "### Unknown value";
  432.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  433.     }
  434.     
  435.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAProgressMsg (%08x) --> %s", caHand, valueStr);
  436.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtDN));            
  437.     PutLine (gLogWindow, "       name          = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtName));
  438.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtSubaddress));
  439.     PutLine (gLogWindow, "       dialType      = %d", ((CAGenericMsgRec*) msgInfo)->dialType);
  440. }
  441.  
  442.  
  443. void    HandleCAOutgoingMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  444. {
  445. #pragma unused (mtype, msgInfo)
  446.  
  447.     DNWindowPtr    dnWindow;
  448.     
  449.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAOutgoingMsg (%08x) --> %s", caHand, (value)?"programmatic":"physical");
  450.     
  451.     if (caHand != nil)
  452.         if (((*caHand)->userData) == nil) {        // (userData == nil) means there is no caWindow associated
  453.                                                 // with this CA, so create its caWindow.
  454.             gAvailableCA = caHand;
  455.             
  456.             dnWindow = GetDNWindow (caHand);
  457.             if (dnWindow != nil)
  458.                 AppendCAList (dnWindow, caHand);
  459.             else
  460.                 PutCLine (gLogWindow, kErrorColor, "### Can't find the corresponding dnWindow");
  461.         }
  462. }
  463.  
  464.  
  465. void    HandleCADisconMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  466. {
  467. #pragma unused (msgInfo)
  468.  
  469.     char * valueStr;
  470.     
  471.     switch (value) {
  472.         case telCADNormal :
  473.             valueStr = "telCADNormal";
  474.             break;
  475.         case telCADBusy :
  476.             valueStr = "telCADBusy";
  477.             break;
  478.         case telCADNoResponse :
  479.             valueStr = "telCADNoResponse";
  480.             break;
  481.         case telCADRejected :
  482.             valueStr = "telCADRejected";
  483.             break;
  484.         case telCADNumberChanged :
  485.             valueStr = "telCADNumberChanged";
  486.             break;
  487.         case telCADInvalidDest :
  488.             valueStr = "telCADInvalidDest";
  489.             break;
  490.         case telCADFacilityRejected :
  491.             valueStr = "telCADFacilityRejected";
  492.             break;
  493.         case telCADUnobtainableDest :
  494.             valueStr = "telCADUnobtainableDest";
  495.             break;
  496.         case telCADCongested :
  497.             valueStr = "telCADCongested";
  498.             break;
  499.         case telCADIncompatibleDest :
  500.             valueStr = "telCADIncompatibleDest";
  501.             break;
  502.         case telCADTimeout :
  503.             valueStr = "telCADTimeout";
  504.             break;
  505.         case telCADUnknown :
  506.             valueStr = "telCADUnknown";
  507.             break;
  508.         default :
  509.             valueStr = "### Unknown value";
  510.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  511.     }
  512.     
  513.     PutCLine (gLogWindow, kCAMsgColor, "::: telCADisconnectMsg (%08x) --> %s (by %s user)", caHand, valueStr, (mtype)?"remote":"local");
  514. }
  515.  
  516.  
  517. void    HandleCAActiveMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  518. {
  519. #pragma unused (mtype, value, msgInfo)
  520.     CAWindowPtr    caWindow;
  521.     
  522.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAActiveMsg (%08x)", caHand);
  523.  
  524.     if (caHand != nil) {
  525.         caWindow = (CAWindowPtr) (*caHand)->userData;
  526.         SetCtlValue (caWindow->fHold, false);
  527.     }
  528. }
  529.  
  530.  
  531. void    HandleCAConfMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  532. {
  533. #pragma unused (mtype)
  534.     char * valueStr;
  535.     
  536.     switch (value) {
  537.         case telConferencePrepFailed :
  538.             valueStr = "telConferencePrepFailed";
  539.             break;
  540.         case telConferencePending :
  541.             valueStr = "telConferencePending";
  542.             break;
  543.         case telConferenceEstFailed :
  544.             valueStr = "telConferenceEstFailed";
  545.             break;
  546.         case telConferenceEst :
  547.             valueStr = "telConferenceEst";
  548.             break;
  549.         default :
  550.             valueStr = "### Unknown value";
  551.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  552.     }
  553.     
  554.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAConferenceMsg (%08x) --> %s", caHand, valueStr);
  555.     PutLine (gLogWindow, "       relatedCA = %08x", ((CAConfMsgRec*) msgInfo)->relatedCA);
  556. }
  557.  
  558.  
  559. void    HandleCATransfMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  560. {
  561. #pragma unused (mtype)
  562.     char * valueStr;
  563.     Str255    tString;
  564.     
  565.     switch (value) {
  566.         case telTransferPrepFailed :
  567.             valueStr = "telTransferPrepFailed";
  568.             break;
  569.         case telTransferPending :
  570.             valueStr = "telTransferPending";
  571.             break;
  572.         case telTransferEst :
  573.             valueStr = "telTransferEst";
  574.             break;
  575.         case telTransferFailed :
  576.             valueStr = "telTransferFailed";
  577.             break;
  578.         case telTransferred :
  579.             valueStr = "telTransferred";
  580.             break;
  581.         default :
  582.             valueStr = "### Unknown value";
  583.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  584.     }
  585.     
  586.     PutCLine (gLogWindow, kCAMsgColor, "::: telCATransferMsg (%08x) --> %s", caHand, valueStr);
  587.     
  588.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CATransfMsgRec*) msgInfo)->rmtDN));
  589.     PutLine (gLogWindow, "       rmtName       = %s", ConvertToCString ((char *) tString, (char *) ((CATransfMsgRec*) msgInfo)->rmtName));
  590.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CATransfMsgRec*) msgInfo)->rmtSubaddress));
  591.     
  592.     PutLine (gLogWindow, "       dialType      = %d", ((CATransfMsgRec*) msgInfo)->dialType);
  593.     PutLine (gLogWindow, "       prepCA        = %08x", ((CATransfMsgRec*) msgInfo)->prepCA);
  594. }
  595.  
  596.  
  597. void    HandleCAHeldMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  598. {
  599. #pragma unused (mtype, msgInfo)
  600.     char         *valueStr;
  601.     CAWindowPtr    caWindow;
  602.     
  603.     switch (value) {
  604.         case telHoldCleared :
  605.             valueStr = "telHoldCleared";
  606.             break;
  607.         case telHoldEst :
  608.             valueStr = "telHoldEst";
  609.             break;
  610.         case telHoldFailed :
  611.             valueStr = "telHoldFailed";
  612.             break;
  613.         default :
  614.             valueStr = "### Unknown value";
  615.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  616.     }
  617.     
  618.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAHoldMsg (%08x) --> %s", caHand, valueStr);
  619.     
  620.     if ((caHand != nil) && ((value == telHoldCleared) || (value == telHoldEst))) {
  621.         caWindow = (CAWindowPtr) (*caHand)->userData;
  622.         SetCtlValue (caWindow->fHold, (value == telHoldEst));
  623.     }
  624. }
  625.  
  626.  
  627. void    HandleCADigitsMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  628. {
  629. #pragma unused (msgInfo)
  630.     PutCLine (gLogWindow, kCAMsgColor, "::: telCADigitsMsg    (%08x) --> %c (%s)", caHand, value, (mtype)?"telDigitNotAudible":"telDigitAudible");
  631. }
  632.  
  633.  
  634. void    HandleCAParkedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  635. {
  636. #pragma unused (mtype)
  637.     char * valueStr;
  638.     Str255    tString;
  639.     
  640.     switch (value) {
  641.         case telCallParkEst :
  642.             valueStr = "telCallParkEst";
  643.             break;
  644.         case telCallParkRetrieveEst :
  645.             valueStr = "telCallParkRetrieveEst";
  646.             break;
  647.         case telCallParkFailed :
  648.             valueStr = "telCallParkFailed";
  649.             break;
  650.         case telCallParkRetrieveFailed :
  651.             valueStr = "telCallParkRetrieveFailed";
  652.             break;
  653.         case telCallParkRecall :
  654.             valueStr = "telCallParkRecall";
  655.             break;
  656.         default :
  657.             valueStr = "### Unknown value";
  658.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  659.     }
  660.     
  661.     PutCLine (gLogWindow, kCAMsgColor, "::: telCACallParkMsg (%08x) --> %s", caHand, valueStr);
  662.     
  663.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtDN));
  664.     PutLine (gLogWindow, "       name          = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtName));
  665.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtSubaddress));
  666.     
  667.     PutLine (gLogWindow, "       dialType      = %d", ((CAGenericMsgRec*) msgInfo)->dialType);
  668. }
  669.  
  670.  
  671. void    HandleCACallBackMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  672. {
  673.     char * valueStr;
  674.     Str255    tString;
  675.     
  676.     switch (value) {
  677.         case telCallbackCleared :
  678.             valueStr = "telCallbackCleared";
  679.             break;
  680.         case telCallbackEst :
  681.             valueStr = "telCallbackEst";
  682.             break;
  683.         case telCallbackNowAvail :
  684.             valueStr = "telCallbackNowAvail";
  685.             break;
  686.         case telCallbackFailed :
  687.             valueStr = "telCallbackFailed";
  688.             break;
  689.         case telCallbackDesired :
  690.             valueStr = "telCallbackDesired";
  691.             break;
  692.         case telCallbackDesiredCleared :
  693.             valueStr = "telCallbackDesiredCleared";
  694.             break;
  695.         case telCalledback :
  696.             valueStr = "telCalledback";
  697.             break;
  698.         default :
  699.             valueStr = "### Unknown value";
  700.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  701.     }
  702.     
  703.     PutCLine (gLogWindow, kCAMsgColor, "::: telCACallbackMsg (%08x) --> %s, cbRef = %d", caHand, valueStr, mtype);
  704.     
  705.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtDN));
  706.     PutLine (gLogWindow, "       name          = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtName));
  707.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtSubaddress));
  708.     
  709.     PutLine (gLogWindow, "       dialType      = %d", ((CAGenericMsgRec*) msgInfo)->dialType);
  710. }
  711.  
  712.  
  713. void    HandleCARejectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  714. {
  715. #pragma unused (mtype, msgInfo)
  716.     char * valueStr;
  717.     
  718.     switch (value) {
  719.         case telCallRejectFailed :
  720.             valueStr = "telCallRejectFailed";
  721.             break;
  722.         case telCallRejectEst :
  723.             valueStr = "telCallRejectEst";
  724.             break;
  725.         case telCallRejected :
  726.             valueStr = "telCallRejected";
  727.             break;
  728.         default :
  729.             valueStr = "### Unknown value";
  730.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  731.     }
  732.     
  733.     PutCLine (gLogWindow, kCAMsgColor, "::: telCARejectMsg (%08x) --> %s", caHand, valueStr);
  734. }
  735.  
  736.  
  737. void    HandleCADeflectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  738. {
  739. #pragma unused (mtype)
  740.     char * valueStr;
  741.     Str255    tString;
  742.     
  743.     switch (value) {
  744.         case telCallDeflectFailed :
  745.             valueStr = "telCallDeflectFailed";
  746.             break;
  747.         case telCallDeflectEst :
  748.             valueStr = "telCallDeflectEst";
  749.             break;
  750.         case telCallDeflectRecall :
  751.             valueStr = "telCallDeflectRecall";
  752.             break;
  753.         case telCallDeflected :
  754.             valueStr = "telCallDeflected";
  755.             break;
  756.         case telAutoDeflectNoAnswer :
  757.             valueStr = "telAutoDeflectNoAnswer";
  758.             break;
  759.         case telAutoDeflectBusy :
  760.             valueStr = "telAutoDeflectBusy";
  761.             break;
  762.         case telAutoDeflectImmediate :
  763.             valueStr = "telAutoDeflectImmediate";
  764.             break;
  765.         default :
  766.             valueStr = "### Unknown value";
  767.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  768.     }
  769.     
  770.     PutCLine (gLogWindow, kCAMsgColor, "::: telCADeflectMsg (%08x) --> %s", caHand, valueStr);
  771.     
  772.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtDN));
  773.     PutLine (gLogWindow, "       name          = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtName));
  774.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtSubaddress));
  775.     
  776.     PutLine (gLogWindow, "       dialType      = %d", ((CAGenericMsgRec*) msgInfo)->dialType);
  777. }
  778.  
  779.  
  780. void    HandleCAForwardedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  781. {
  782. #pragma unused (mtype)
  783.     char * valueStr;
  784.     Str255    tString;
  785.     
  786.     switch (value) {
  787.         case telForwardImmediate :
  788.             valueStr = "telForwardImmediate";
  789.             break;
  790.         case telForwardBusy :
  791.             valueStr = "telForwardBusy";
  792.             break;
  793.         case telForwardNoAnswer :
  794.             valueStr = "telForwardNoAnswer";
  795.             break;
  796.         case telForwardBusyNA :
  797.             valueStr = "telForwardBusyNA";
  798.             break;
  799.         case telForwardTypeUnknown :
  800.             valueStr = "telForwardTypeUnknown";
  801.             break;
  802.         default :
  803.             valueStr = "### Unknown value";
  804.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  805.     }
  806.     
  807.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAForwardMsg (%08x) --> %s", caHand, valueStr);
  808.     
  809.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtDN));
  810.     PutLine (gLogWindow, "       name          = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtName));
  811.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtSubaddress));
  812.     
  813.     PutLine (gLogWindow, "       dialType      = %d", ((CAGenericMsgRec*) msgInfo)->dialType);
  814. }
  815.  
  816.  
  817. void    HandleCAConfSplitMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  818. {
  819. #pragma unused (mtype)
  820.     char * valueStr;
  821.     
  822.     switch (value) {
  823.         case telConferenceSplitFailed :
  824.             valueStr = "telConferenceSplitFailed";
  825.             break;
  826.         case telConferenceSplitEst :
  827.             valueStr = "telConferenceSplitEst";
  828.             break;
  829.         default :
  830.             valueStr = "### Unknown value";
  831.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  832.     }
  833.     
  834.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAConferenceSplitMsg (%08x) --> %s", caHand, valueStr);
  835.     PutLine (gLogWindow, "       relatedCA = %08x", ((CAConfMsgRec*) msgInfo)->relatedCA);
  836. }
  837.  
  838.  
  839. void    HandleCAConfDropMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  840. {
  841. #pragma unused (mtype)
  842.     char * valueStr;
  843.     
  844.     switch (value) {
  845.         case telConferenceDropFailed :
  846.             valueStr = "telConferenceDropFailed";
  847.             break;
  848.         case telConferenceDropped :
  849.             valueStr = "telConferenceDropped";
  850.             break;
  851.         default :
  852.             valueStr = "### Unknown value";
  853.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  854.     }
  855.     
  856.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAConferenceDropMsg (%08x) --> %s", caHand, valueStr);
  857.     PutLine (gLogWindow, "       relatedCA = %08x", ((CAConfMsgRec*) msgInfo)->relatedCA);
  858. }
  859.  
  860.  
  861. void    HandleCAQueuedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  862. {
  863. #pragma unused (mtype, value, msgInfo)
  864.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAQueuedMsg (%08x)", caHand);
  865. }
  866.  
  867.  
  868. void    HandleCAInUseMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  869. {
  870. #pragma unused (mtype, value, msgInfo)
  871.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAInUseMsg (%08x)", caHand);
  872. }
  873.  
  874.  
  875. void    HandleCAPickUpMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  876. {
  877. #pragma unused (mtype)
  878.     char * valueStr;
  879.     Str255    tString;
  880.     
  881.     switch (value) {
  882.         case telCallPickupEst :
  883.             valueStr = "telCallPickupEst";
  884.             break;
  885.         case telCallPickupFailed :
  886.             valueStr = "telCallPickupFailed";
  887.             break;
  888.         case telCallPickedUp :
  889.             valueStr = "telCallPickedUp";
  890.             break;
  891.         default :
  892.             valueStr = "### Unknown value";
  893.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  894.     }
  895.     
  896.     PutCLine (gLogWindow, kCAMsgColor, "::: telCACallPickupMsg (%08x) --> %s", caHand, valueStr);
  897.     
  898.     PutLine (gLogWindow, "       rmtDN         = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtDN));
  899.     PutLine (gLogWindow, "       name          = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtName));
  900.     PutLine (gLogWindow, "       rmtSubaddress = %s", ConvertToCString ((char *) tString, (char *) ((CAGenericMsgRec*) msgInfo)->rmtSubaddress));
  901.     
  902.     PutLine (gLogWindow, "       dialType      = %d", ((CAGenericMsgRec*) msgInfo)->dialType);
  903. }
  904.  
  905.  
  906. void    HandleCAPagingMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  907. {
  908. #pragma unused (msgInfo)
  909.     char * valueStr;
  910.     
  911.     switch (value) {
  912.         case telPageEst :
  913.             valueStr = "telPageEst";
  914.             break;
  915.         case telPageComplete :
  916.             valueStr = "telPageComplete";
  917.             break;
  918.         case telPageFailed :
  919.             valueStr = "telPageFailed";
  920.             break;
  921.         default :
  922.             valueStr = "### Unknown value";
  923.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  924.     }
  925.     
  926.     PutCLine (gLogWindow, kCAMsgColor, "::: caPageMsg (%08x) --> %s, pageID = %d", caHand, valueStr, mtype);
  927. }
  928.  
  929.  
  930. void    HandleCAInterComMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  931. {
  932. #pragma unused (mtype, msgInfo)
  933.     char * valueStr;
  934.     
  935.     switch (value) {
  936.         case telIntercomEst :
  937.             valueStr = "telIntercomEst";
  938.             break;
  939.         case telIntercomComplete :
  940.             valueStr = "telIntercomComplete";
  941.             break;
  942.         case telIntercomFailed :
  943.             valueStr = "telIntercomFailed";
  944.             break;
  945.         default :
  946.             valueStr = "### Unknown value";
  947.             PutCLine (gLogWindow, kErrorColor, "### Unknown value : %d", value);
  948.     }
  949.     
  950.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAIntercomMsg (%08x) --> %s", caHand, valueStr);
  951. }
  952.  
  953.  
  954. void    HandleCAModemToneMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  955. {
  956. #pragma unused (mtype, msgInfo)
  957.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAModemToneMsg (%08x) --> %s", caHand, (value)?"telModemToneCleared":"telModemToneDetected");
  958. }
  959.  
  960.  
  961. void    HandleCAFaxToneMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  962. {
  963. #pragma unused (mtype, msgInfo)
  964.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAFaxToneMsg (%08x) --> %s", caHand, (value)?"telFaxToneCleared":"telFaxToneDetected");
  965. }
  966.  
  967.  
  968. void    HandleCAIdleMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  969. {
  970. #pragma unused (mtype, value, msgInfo)
  971.  
  972.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAIdleMsg (%08x)", caHand);
  973.     
  974.     if (caHand != nil) {
  975.         if (gAvailableCA == caHand)
  976.             gAvailableCA = nil;
  977.         RemoveFromCAList ((DNWindowPtr) (*caHand)->refCon, caHand);
  978.     }
  979. }
  980.  
  981.  
  982. void    HandleCASuccessiveAlertMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  983. {
  984. #pragma unused (mtype, msgInfo)
  985.     PutCLine (gLogWindow, kCAMsgColor, "::: telCASuccessiveAlertMsg (%08x) --> numOfRings = %d", caHand, value);
  986. }
  987.  
  988.  
  989. void    HandleCAUserUserInfoMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  990. {
  991. #pragma unused (mtype, value)
  992.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAUserUserInfoMsg (%08x) --> %s", caHand, ((CAUserUserInfoMsgRec*) msgInfo)->userUserInfo);
  993. }
  994.  
  995.  
  996.  
  997. void    HandleCAHandOffMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  998. {
  999. #pragma unused (msgInfo)
  1000.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAHandOffMsg (%08x) --> Answered on TollSaverRingCount = %s", caHand, (mtype)?"Yes":"No");
  1001.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAHandOffMsg (%08x) --> Voice energy detected = %s", caHand, (value)?"Energy":"NonEnergy");
  1002. }
  1003.  
  1004. void    HandleCAVoiceDetectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  1005. {
  1006. #pragma unused (mtype, value, msgInfo)
  1007.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAVoiceDetectedMsg (%08x)", caHand);
  1008. }
  1009.  
  1010. void    HandleCASilenceDetectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  1011. {
  1012. #pragma unused (mtype, msgInfo)
  1013.     PutCLine (gLogWindow, kCAMsgColor, "::: telCASilenceDetectedMsg (%08x) --> Silence period = %d", caHand, value);
  1014. }
  1015.  
  1016. //void    HandleCAEnergyDetectedMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  1017. //{
  1018. //    char * timeStampStr = nil;
  1019. //
  1020. //    PutCLine (gLogWindow, kCAMsgColor, "::: telCAEnergyDetectedMsg (%08x) --> Energy type = %s", caHand, (mtype)?"VoiceEnergy":"MiscEnergy");
  1021. //    PutCLine (gLogWindow, kCAMsgColor, "::: telCAEnergyDetectedMsg (%08x) --> Energy detected = %s", caHand, (value)?"Energy":"NonEnergy");
  1022. //
  1023. //    PutLine (gLogWindow, "       energyPeriod    = %lu", ((CAEnergyDetMsgRec*) msgInfo)->energyPeriod);
  1024. //    PutLine (gLogWindow, "       nonEnergyPeriod = %lu", ((CAEnergyDetMsgRec*) msgInfo)->nonEnergyPeriod);
  1025. //    PutLine (gLogWindow, "       timeStamp       = %lu", ((CAEnergyDetMsgRec*) msgInfo)->timeStamp);        /* TEMPORARY */
  1026. //
  1027. //    iudatestring (((CAEnergyDetMsgRec*) msgInfo)->timeStamp, shortDate, timeStampStr);
  1028. //
  1029. //    PutLine (gLogWindow, "       timeStamp       = %s", timeStampStr);
  1030. //}
  1031.  
  1032.  
  1033. void    HandleCADigitsImmMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  1034. {
  1035. #pragma unused (msgInfo)
  1036.     PutCLine (gLogWindow, kCAMsgColor, "::: telCADigitsImmMsg (%08x) --> %c (%s)", caHand, value, (mtype)?"telDigitNotAudible":"telDigitAudible");
  1037. }
  1038.  
  1039.  
  1040.  
  1041. void    HandleCAOtherMsg (TELCAHandle caHand, short mtype, short value, Ptr msgInfo)
  1042. {
  1043. #pragma unused (msgInfo)
  1044.     PutCLine (gLogWindow, kCAMsgColor, "::: telCAOtherMsg (%08x) --> (vendor defined) type = %d, value = %d",caHand,  mtype, value);
  1045. }
  1046.  
  1047.  
  1048. void    GetCAStateStr (TELCAHandle caHand, char **stateStr)
  1049. {
  1050.     OSErr    errCode;
  1051.     short    state;
  1052.     
  1053.     if (caHand != nil) {
  1054.         if ((errCode = TELGetCAState (caHand, &state)) == noErr) {
  1055.             switch (state) {
  1056.                 case telCAIdleState :
  1057.                     *stateStr = "idle";
  1058.                     break;
  1059.                 case telCAInUseState :
  1060.                     *stateStr = "in use";
  1061.                     break;
  1062.                 case telCAOfferState :
  1063.                     *stateStr = "offer";
  1064.                     break;
  1065.                 case telCAQueuedState :
  1066.                     *stateStr = "queued";
  1067.                     break;
  1068.                 case telCAAlertingState :
  1069.                     *stateStr = "alerting";
  1070.                     break;
  1071.                 case telCADialToneState :
  1072.                     *stateStr = "dial tone";
  1073.                     break;
  1074.                 case telCADialingState :
  1075.                     *stateStr = "dialing";
  1076.                     break;
  1077.                 case telCAWaitingState :
  1078.                     *stateStr = "waiting";
  1079.                     break;
  1080.                 case telCARingingState :
  1081.                     *stateStr = "ringing";
  1082.                     break;
  1083.                 case telCABusyState :
  1084.                     *stateStr = "busy";
  1085.                     break;
  1086.                 case telCAHeldState :
  1087.                     *stateStr = "held";
  1088.                     break;
  1089.                 case telCAConferencedState :
  1090.                     *stateStr = "conferenced";
  1091.                     break;
  1092.                 case telCAActiveState :
  1093.                     *stateStr = "active";
  1094.                     break;
  1095.                 case telCAReorderState :
  1096.                     *stateStr = "reorder";
  1097.                     break;
  1098.                 case telCAConferencedHeldState :
  1099.                     *stateStr = "conference held";
  1100.                     break;
  1101.                 case telCAUnknownState :
  1102.                     *stateStr = "unknown state";
  1103.                     break;
  1104.                 default :
  1105.                     *stateStr = "### undefined state";
  1106.             }
  1107.         }
  1108. //        else
  1109. //            PutCLine (gLogWindow, kErrorColor, "### TELGetCAState fails : %d", errCode);
  1110.     }
  1111. }
  1112.  
  1113.  
  1114. #pragma segment Dump
  1115. void    DumpCAFlags (TELCAHandle caHand)
  1116. {
  1117.     OSErr    errCode;
  1118.     long    caFeatureFlags, caOtherFeatures;
  1119.     
  1120.     if (caHand != nil) {
  1121.         if ((errCode = TELGetCAFlags (caHand, &caFeatureFlags, &caOtherFeatures)) == noErr) {
  1122.             PutLine (gLogWindow, "=============== caFeatureFlags ===============");
  1123.             PutLine (gLogWindow, " featureFlags : %08x", caFeatureFlags);
  1124.             PutLine (gLogWindow, " %c holdSub", (caFeatureFlags & holdSub)?checkChar:spaceChar);
  1125.             PutLine (gLogWindow, " %c holdAvail", (caFeatureFlags & holdAvail)?checkChar:spaceChar);
  1126.             PutLine (gLogWindow, " %c holdActive", (caFeatureFlags & holdActive)?checkChar:spaceChar);
  1127.             PutLine (gLogWindow, " %c conferenceSub", (caFeatureFlags & conferenceSub)?checkChar:spaceChar);
  1128.             PutLine (gLogWindow, " %c conferenceAvail", (caFeatureFlags & conferenceAvail)?checkChar:spaceChar);
  1129.             PutLine (gLogWindow, " %c conferenceActive", (caFeatureFlags & conferenceActive)?checkChar:spaceChar);
  1130.             PutLine (gLogWindow, " %c conferenceDropSub", (caFeatureFlags & conferenceDropSub)?checkChar:spaceChar);
  1131.             PutLine (gLogWindow, " %c conferenceDropAvail", (caFeatureFlags & conferenceDropAvail)?checkChar:spaceChar);
  1132.             PutLine (gLogWindow, " %c conferenceSplitSub", (caFeatureFlags & conferenceSplitSub)?checkChar:spaceChar);
  1133.             PutLine (gLogWindow, " %c conferenceSplitAvail", (caFeatureFlags & conferenceSplitAvail)?checkChar:spaceChar);
  1134.             PutLine (gLogWindow, " %c numToConferenceRequired", (caFeatureFlags & numToConferenceRequired)?checkChar:spaceChar);
  1135.             PutLine (gLogWindow, " %c transferSub", (caFeatureFlags & transferSub)?checkChar:spaceChar);
  1136.             PutLine (gLogWindow, " %c transferAvail", (caFeatureFlags & transferAvail)?checkChar:spaceChar);
  1137.             PutLine (gLogWindow, " %c transferActive", (caFeatureFlags & transferActive)?checkChar:spaceChar);
  1138.             PutLine (gLogWindow, " %c caRelated", (caFeatureFlags & caRelated)?checkChar:spaceChar);
  1139.             PutLine (gLogWindow, "  remainder     : %08x", (caFeatureFlags & (0xFFFFFFFF << 15)));
  1140.             PutLine (gLogWindow, "=============== caOtherFeatures ===============");
  1141.             PutLine (gLogWindow, " otherFeatures : %08x", caOtherFeatures);
  1142.             PutLine (gLogWindow, " %c callbackSub", (caOtherFeatures & callbackSub)?checkChar:spaceChar);
  1143.             PutLine (gLogWindow, " %c callbackAvail", (caOtherFeatures & callbackAvail)?checkChar:spaceChar);
  1144.             PutLine (gLogWindow, " %c callbackActive", (caOtherFeatures & callbackActive)?checkChar:spaceChar);
  1145.             PutLine (gLogWindow, " %c callbackClearSub", (caOtherFeatures & callbackClearSub)?checkChar:spaceChar);
  1146.             PutLine (gLogWindow, " %c callbackNowSub", (caOtherFeatures & callbackNowSub)?checkChar:spaceChar);
  1147.             PutLine (gLogWindow, " %c callbackNowAvail", (caOtherFeatures & callbackNowAvail)?checkChar:spaceChar);
  1148.             PutLine (gLogWindow, " %c callbackBusy", (caOtherFeatures & callbackBusy)?checkChar:spaceChar);
  1149.             PutLine (gLogWindow, " %c callbackNoAnswer", (caOtherFeatures & callbackNoAnswer)?checkChar:spaceChar);
  1150.             PutLine (gLogWindow, " %c callbackReturnsRef", (caOtherFeatures & callbackReturnsRef)?checkChar:spaceChar);
  1151.             PutLine (gLogWindow, " %c parkSub", (caOtherFeatures & parkSub)?checkChar:spaceChar);
  1152.             PutLine (gLogWindow, " %c parkAvail", (caOtherFeatures & parkAvail)?checkChar:spaceChar);
  1153.             PutLine (gLogWindow, " %c parkActive", (caOtherFeatures & parkActive)?checkChar:spaceChar);
  1154.             PutLine (gLogWindow, " %c parkRetrieveSub", (caOtherFeatures & parkRetrieveSub)?checkChar:spaceChar);
  1155.             PutLine (gLogWindow, " %c parkRetrieveWithID", (caOtherFeatures & parkRetrieveWithID)?checkChar:spaceChar);
  1156.             PutLine (gLogWindow, " %c parkWithReturnedID", (caOtherFeatures & parkWithReturnedID)?checkChar:spaceChar);
  1157.             PutLine (gLogWindow, " %c parkWithGivenID", (caOtherFeatures & parkWithGivenID)?checkChar:spaceChar);
  1158.             PutLine (gLogWindow, " %c rejectable", (caOtherFeatures & rejectable)?checkChar:spaceChar);
  1159.             PutLine (gLogWindow, " %c deflectable", (caOtherFeatures & deflectable)?checkChar:spaceChar);
  1160.             PutLine (gLogWindow, " %c acceptable", (caOtherFeatures & acceptable)?checkChar:spaceChar);
  1161.             PutLine (gLogWindow, " %c voiceDetected", (caOtherFeatures & voiceDetected)?checkChar:spaceChar);
  1162.             PutLine (gLogWindow, " %c callAnswdTSRings", (caOtherFeatures & callAnswdTSRings)?checkChar:spaceChar);
  1163.             PutLine (gLogWindow, "  remainder     : %08x", (caOtherFeatures & (0xFFFFFFFF << 21)));
  1164.         } else
  1165.             PutCLine (gLogWindow, kErrorColor, "### TELGetCAFlags fails : %d", errCode);
  1166.     }
  1167. }
  1168.  
  1169.  
  1170. #pragma segment Dump
  1171. void    DumpCAState (TELCAHandle caHand)
  1172. {
  1173.     OSErr    errCode;
  1174.     short    state;
  1175.     char    *stateStr;
  1176.     
  1177.     if (caHand != nil) {
  1178.         if ((errCode = TELGetCAState (caHand, &state)) == noErr) {
  1179.             switch (state) {
  1180.                 case telCAIdleState :
  1181.                     stateStr = "idle";
  1182.                     break;
  1183.                 case telCAInUseState :
  1184.                     stateStr = "in use";
  1185.                     break;
  1186.                 case telCAOfferState :
  1187.                     stateStr = "offer";
  1188.                     break;
  1189.                 case telCAQueuedState :
  1190.                     stateStr = "queued";
  1191.                     break;
  1192.                 case telCAAlertingState :
  1193.                     stateStr = "alerting";
  1194.                     break;
  1195.                 case telCADialToneState :
  1196.                     stateStr = "dial tone";
  1197.                     break;
  1198.                 case telCADialingState :
  1199.                     stateStr = "dialing";
  1200.                     break;
  1201.                 case telCAWaitingState :
  1202.                     stateStr = "waiting";
  1203.                     break;
  1204.                 case telCARingingState :
  1205.                     stateStr = "ringing";
  1206.                     break;
  1207.                 case telCABusyState :
  1208.                     stateStr = "busy";
  1209.                     break;
  1210.                 case telCAHeldState :
  1211.                     stateStr = "held";
  1212.                     break;
  1213.                 case telCAConferencedState :
  1214.                     stateStr = "conferenced";
  1215.                     break;
  1216.                 case telCAActiveState :
  1217.                     stateStr = "active";
  1218.                     break;
  1219.                 case telCAReorderState :
  1220.                     stateStr = "reorder";
  1221.                     break;
  1222.                 case telCAConferencedHeldState :
  1223.                     stateStr = "conference held";
  1224.                     break;
  1225.                 case telCAUnknownState :
  1226.                     stateStr = "unknown state";
  1227.                     break;
  1228.                 default :
  1229.                     stateStr = "### undefined state";
  1230.             }
  1231.             PutLine (gLogWindow, "=============== CA State ===============");
  1232.             PutLine (gLogWindow, " current castate (%d) = %s", state, stateStr);
  1233.         } else
  1234.             PutCLine (gLogWindow, kErrorColor, "### TELGetCAState fails : %d", errCode);
  1235.     }
  1236. }
  1237.  
  1238.  
  1239. #pragma segment Dump
  1240. void    DumpCAInfo (TELCAHandle caHand)
  1241. {
  1242.     OSErr        errCode;
  1243.     long        flags;
  1244.     Str255        tString;
  1245.     
  1246.     if (caHand != nil) {
  1247.         if ((errCode = TELGetCAInfo (caHand)) == noErr) {
  1248.             PutLine (gLogWindow, "=============== TELCARecord ===============");
  1249.             PutLine (gLogWindow, " caRef           : %04x", (**caHand).caRef);
  1250.             PutLine (gLogWindow, " hTELDN          : %08x", (**caHand).hTELDN);
  1251.             PutLine (gLogWindow, " hTEL            : %08x", (**caHand).hTEL);
  1252.             PutLine (gLogWindow, " caState         : %d", (**caHand).caState);
  1253.             PutLine (gLogWindow, " relatedCA       : %08x", (**caHand).relatedCA);
  1254.             PutLine (gLogWindow, " connectTime     : %ld", (**caHand).connectTime);
  1255.             PutLine (gLogWindow, " intExt          : %d", (**caHand).intExt);
  1256.             PutLine (gLogWindow, " callType        : %d", (**caHand).callType);
  1257.             PutLine (gLogWindow, " dialType        : %d", (**caHand).dialType);
  1258.             PutLine (gLogWindow, " bearerType      : %d", (**caHand).bearerType);
  1259.             PutLine (gLogWindow, " rate            : %d", (**caHand).rate);
  1260.             PutLine (gLogWindow, " rmtDN           : %s", ConvertToCString ((char *) tString, (char *) (**caHand).rmtDN));
  1261.             PutLine (gLogWindow, " rmtPartyName    : %s", ConvertToCString ((char *) tString, (char *) (**caHand).rmtPartyName));
  1262.             PutLine (gLogWindow, " rmtSubaddress   : %s", ConvertToCString ((char *) tString, (char *) (**caHand).rmtSubaddress));
  1263.             PutLine (gLogWindow, " routeDN         : %s", ConvertToCString ((char *) tString, (char *) (**caHand).routeDN));
  1264.             PutLine (gLogWindow, " routePartyName  : %s", ConvertToCString ((char *) tString, (char *) (**caHand).routePartyName));
  1265.             PutLine (gLogWindow, " routeSubaddress : %s", ConvertToCString ((char *) tString, (char *) (**caHand).routeSubaddress));
  1266.             PutLine (gLogWindow, " priority        : %d", (**caHand).priority);
  1267.             PutLine (gLogWindow, " conferenceLimit : %d", (**caHand).conferenceLimit);
  1268.  
  1269.             flags = (**caHand).featureFlags;
  1270.             PutLine (gLogWindow, " featureFlags    : %08x", flags);
  1271.             
  1272.             flags = (**caHand).otherFeatures;
  1273.             PutLine (gLogWindow, " otherFeatures   : %08x", flags);
  1274.  
  1275.             PutLine (gLogWindow, " telCAPrivate    : %08x", (**caHand).telCAPrivate);
  1276.             PutLine (gLogWindow, " refCon          : %08x", (**caHand).refCon);
  1277.             PutLine (gLogWindow, " userData        : %08x", (**caHand).userData);
  1278.  
  1279.             PutLine (gLogWindow, " reserved        : %08x", (**caHand).reserved);
  1280.         } else
  1281.             PutCLine (gLogWindow, kErrorColor, "### TELCAGetInfo fails : %d", errCode);
  1282.     }
  1283. }
  1284.  
  1285.  
  1286. #pragma segment Dump
  1287. void    DumpCAEvents (TELDNHandle dnHand)
  1288. {
  1289.     OSErr            errCode;
  1290.     long            eventMask;
  1291.     
  1292.     if (dnHand != nil) {
  1293.         if ((errCode = TELCAEventsSupp (dnHand, &eventMask)) == noErr) {
  1294.             PutLine (gLogWindow, "=============== CAEvents ===============");
  1295.             PutLine (gLogWindow, " mask             : %08x", eventMask);
  1296.             PutLine (gLogWindow, " %c telCAAlertingMsg", (eventMask & telCAAlertingMsg)?checkChar:spaceChar);
  1297.             PutLine (gLogWindow, " %c telCAOfferMsg", (eventMask & telCAOfferMsg)?checkChar:spaceChar);
  1298.             PutLine (gLogWindow, " %c telCAProgressMsg", (eventMask & telCAProgressMsg)?checkChar:spaceChar);
  1299.             PutLine (gLogWindow, " %c telCAOutgoingMsg", (eventMask & telCAOutgoingMsg)?checkChar:spaceChar);
  1300.             PutLine (gLogWindow, " %c telCADisconnectMsg", (eventMask & telCADisconnectMsg)?checkChar:spaceChar);
  1301.             PutLine (gLogWindow, " %c telCAActiveMsg", (eventMask & telCAActiveMsg)?checkChar:spaceChar);
  1302.             PutLine (gLogWindow, " %c telCAConferenceMsg", (eventMask & telCAConferenceMsg)?checkChar:spaceChar);
  1303.             PutLine (gLogWindow, " %c telCATransferMsg", (eventMask & telCATransferMsg)?checkChar:spaceChar);
  1304.             PutLine (gLogWindow, " %c telCAHoldMsg", (eventMask & telCAHoldMsg)?checkChar:spaceChar);
  1305.             PutLine (gLogWindow, " %c telCADigitsMsg", (eventMask & telCADigitsMsg)?checkChar:spaceChar);    
  1306.             PutLine (gLogWindow, " %c telCACallParkMsg", (eventMask & telCACallParkMsg)?checkChar:spaceChar);
  1307.             PutLine (gLogWindow, " %c telCACallbackMsg", (eventMask & telCACallbackMsg)?checkChar:spaceChar);
  1308.             PutLine (gLogWindow, " %c telCARejectMsg", (eventMask & telCARejectMsg)?checkChar:spaceChar);
  1309.             PutLine (gLogWindow, " %c telCADeflectMsg", (eventMask & telCADeflectMsg)?checkChar:spaceChar);
  1310.             PutLine (gLogWindow, " %c telCAForwardMsg", (eventMask & telCAForwardMsg)?checkChar:spaceChar);
  1311.             PutLine (gLogWindow, " %c telCAConferenceSplitMsg", (eventMask & telCAConferenceSplitMsg)?checkChar:spaceChar);
  1312.             PutLine (gLogWindow, " %c telCAConferenceDropMsg", (eventMask & telCAConferenceDropMsg)?checkChar:spaceChar);
  1313.             PutLine (gLogWindow, " %c telCAQueuedMsg", (eventMask & telCAQueuedMsg)?checkChar:spaceChar);
  1314.             PutLine (gLogWindow, " %c telCAInUseMsg", (eventMask & telCAInUseMsg)?checkChar:spaceChar);
  1315.             PutLine (gLogWindow, " %c telCACallPickupMsg", (eventMask & telCACallPickupMsg)?checkChar:spaceChar);
  1316.             PutLine (gLogWindow, " %c telCAPagingMsg", (eventMask & telCAPagingMsg)?checkChar:spaceChar);
  1317.             PutLine (gLogWindow, " %c telCAIntercomMsg", (eventMask & telCAIntercomMsg)?checkChar:spaceChar);
  1318.             PutLine (gLogWindow, " %c telCAModemToneMsg", (eventMask & telCAModemToneMsg)?checkChar:spaceChar);
  1319.             PutLine (gLogWindow, " %c telCAFaxToneMsg", (eventMask & telCAFaxToneMsg)?checkChar:spaceChar);
  1320.             PutLine (gLogWindow, " %c telCAIdleMsg", (eventMask & telCAIdleMsg)?checkChar:spaceChar);
  1321.             PutLine (gLogWindow, " %c telCASuccessiveAlertMsg", (eventMask & telCASuccessiveAlertMsg)?checkChar:spaceChar);
  1322.             PutLine (gLogWindow, " %c telCAUserUserInfoMsg", (eventMask & telCAUserUserInfoMsg)?checkChar:spaceChar);
  1323.             PutLine (gLogWindow, " %c telCAOtherMsg", (eventMask & telCAOtherMsg)?checkChar:spaceChar);
  1324.             
  1325.             PutLine (gLogWindow, " %c telCAHandOffMsg", (eventMask & telCAHandOffMsg)?checkChar:spaceChar);
  1326.             PutLine (gLogWindow, " %c telCAVoiceDetectedMsg", (eventMask & telCAVoiceDetectedMsg)?checkChar:spaceChar);
  1327.             PutLine (gLogWindow, " %c telCASilenceDetectedMsg", (eventMask & telCASilenceDetectedMsg)?checkChar:spaceChar);
  1328. //            PutLine (gLogWindow, " %c telCAEnergyDetectedMsg", (eventMask & telCAEnergyDetectedMsg)?checkChar:spaceChar);
  1329.             PutLine (gLogWindow, " %c telCADigitsImmMsg", (eventMask & telCADigitsImmMsg)?checkChar:spaceChar);
  1330.             
  1331.             PutLine (gLogWindow, " remainder        : %08x", (eventMask & ~(telAllCAMsgs | telCAOtherMsg)));
  1332.         } else
  1333.             PutCLine (gLogWindow, kErrorColor, "### TELCAEventsSupp fails : %d", errCode);
  1334.     }
  1335. }
  1336.